/**
 * Created by zhong on 2017/10/24.
 *
 * (resolve) =>{require(['../components/test.vue'],resolve)}
 *
 */
import Vue from 'vue'
import store from './vuex'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 定义全局组件
import zmodal from './component/common/modal.vue'
import zbanner from './component/common/banner.vue'
import zfooter from './component/common/footer.vue'
import zhistory from './component/common/goback.vue'
import backhome from './component/common/back-home.vue'


Vue.component('z-modal', zmodal)
Vue.component('z-banner', zbanner)
Vue.component('z-footer', zfooter)
Vue.component('z-history', zhistory)
Vue.component('z-home', backhome)


// 定义组件

const short = (resolve) => {require(['./pages/short.vue'],resolve)}
const home = (resolve) => {require(['./pages/home/home.vue'],resolve)}
const app = (resolve) => {require(['./App.vue'],resolve)}
// 直播
// const live = (resolve) => {require(['./pages/home/home.vue'],resolve)}
// const liveDetails = (resolve) => {require(['./pages/home/home.vue'],resolve)}

//登陆
const login = (resolve) => {require(['./pages/login/login.vue'],resolve)}
const register = (resolve) => {require(['./pages/login/register.vue'],resolve)}
const backpassword = (resolve) => {require(['./pages/login/backpassword.vue'],resolve)}
const qrcode = (resolve) => {require(['./pages/login/qrcode.vue'],resolve)}
const wxlogin = (resolve) => {require(['./pages/login/wxlogin.vue'],resolve)}
const binding = (resolve) => {require(['./pages/login/binding.vue'],resolve)}
const bindingexisting = (resolve) => {require(['./pages/login/bindingexisting.vue'],resolve)}

//概况
const survey = (resolve) => {require(['./pages/home/survey.vue'],resolve)}
const addka = (resolve) => {require(['./pages/home/add.vue'],resolve)}

//写作
const article = (resolve) => {require(['./pages/article/article.vue'],resolve)}
const demand = (resolve) => {require(['./pages/article/demand.vue'],resolve)}
const submission = (resolve) => {require(['./pages/article/submission.vue'],resolve)}
const uuu = (resolve) => {require(['./pages/article/uuu.vue'],resolve)}
const ckFiles = (resolve) => {require(['./pages/article/ckFiles.vue'],resolve)}
const articles = (resolve) => {require(['./pages/article/articles.vue'],resolve)}
const writing = (resolve) => {require(['./pages/article/writing.vue'],resolve)}

//推广
const extension = (resolve) => {require(['./pages/extension/extension.vue'],resolve)}
const market = (resolve) => {require(['./pages/extension/market.vue'],resolve)}
const mytuig = (resolve) => {require(['./pages/extension/mytuig.vue'],resolve)}
const promotiondetails = (resolve) => {require(['./pages/extension/promotiondetails.vue'],resolve)}
// 设置
const setup = (resolve) => {require(['./pages/setup/setup.vue'],resolve)}
const personal = (resolve) => {require(['./pages/setup/personal.vue'],resolve)}
const relation = (resolve) => {require(['./pages/setup/relation.vue'],resolve)}
const password = (resolve) => {require(['./pages/setup/password.vue'],resolve)}
//收入
const finance = (resolve) => {require(['./pages/finance/finance.vue'],resolve)}
const income = (resolve) => {require(['./pages/finance/income.vue'],resolve)}
const settlement = (resolve) => {require(['./pages/finance/settlement.vue'],resolve)}
const bankcard = (resolve) => {require(['./pages/finance/bankcard.vue'],resolve)}

//消息
const notice = (resolve) => {require(['./pages/notice/notice.vue'],resolve)}

// 404错误页面
const error = (resolve) => {require(['./pages/error.vue'],resolve)}

// 创建路由器实例，配置路由规则
const routers = [
    {path: '/d/:shortId', component: short},
    {name:'login',path: '/login', component: login},
    {name:'register',path: '/register', component: register},
    {name:'backpassword',path: '/backpassword', component: backpassword},
    {name:'qrcode',path: '/qrcode', component: qrcode},
    {name:'wxlogin',path: '/wxlogin', component: wxlogin},
    {name:'binding',path: '/binding', component: binding},
    {name:'bindingexisting',path: '/bindingexisting', component: bindingexisting},
    

    {uuu:'register',path: '/uuu', component: uuu},
    {ckFiles:'register',path: '/ckFiles', component: ckFiles},
    {name: 'articles',path:'/articles',component: articles},         //文章详情

    {name: 'addka',path:'/addka',component: addka},  

    {name: 'app',path:'/',component: app}, 

    {name: 'home',path:'/home',component: home, meta: {keepAlive: false},
           children:[
               {name: 'article',path:'/article',component: article,redirect:'/article/demand',
                   children:[
                    {name: 'demand',path:'/article/demand',component: demand},
                    {name: 'submission',path:'/article/submission',component: submission},

                    // {name: 'file',path:'/article/file',component: file},

                   ]
               },
               {name: 'extension',path:'/extension',component: extension,redirect:'/extension/market',
                   children:[
                    {name: 'market',path:'/extension/market',component: market},
                    {name: 'mytuig',path:'/extension/mytuig',component: mytuig},
                    // {name: 'file',path:'/article/file',component: file},

                   ]
               },
               {name: 'setup',path:'/setup',component: setup,redirect:'/setup/personal',
                   children:[
                    {name: 'personal',path:'/setup/personal',component: personal},
                    {name: 'relation',path:'/setup/relation',component: relation},
                    {name: 'password',path:'/setup/password',component: password},
                   ]
               },
           
               
               {name: 'notice',path:'/notice',component: notice},    //消息

               // {name: 'addArticle',path:'/auction/addArticle',component: addArticle},
               {name: 'finance',path:'/finance',component: finance,redirect:'/finance/income',
                  children:[
                    {name: 'income',path:'/finance/income',component: income},
                    {name: 'settlement',path:'/finance/settlement',component: settlement},
                    {name: 'bankcard',path:'/finance/bankcard',component: bankcard},

                   ]
               },
     

               {name: 'survey',path:'/survey',component: survey},              //概况
               {name: 'writing',path:'/writing',component: writing}, //写作
               {name: 'promotiondetails',path:'/promotiondetails',component: promotiondetails}, //推广
       
           ]
       },
    {name: 'err',path:'/s/404',component: error}, //错误跳到404页面
  



    
]

const router = new VueRouter({
    mode: 'history',
    base: __dirname,
    routes:routers
})

export default router